
<template>
	<view class="box">
		<view class="top">
			<image src="../../static/fdj.png"></image>
			<input type="text" @confirm="newsDatas" v-model="state.text"/>
			<view class="sou" @click="newsDatas">搜索</view>
		</view>
		<scroll-view scroll-y="true" lower-threshold="80" @scrolltolower="getGoodsList" class="marTop">
			<view class="all_list">
				<view class="block" v-for="item,index in state.list" :key="index" @click="sheep.$router.go('/pages/index/detail?id='+item.id+'&type=1')">
					<view class="img">
						<image :src="item.show_image" mode=""></image>
					</view>
					<view class="title">
						<image src="../../static/icon_v@2x.png" mode=""></image>
						<text class="ov1">{{item.title}}</text>
					</view>
					<view class="infos ov1">
						{{item.name}}·{{item.age}}·{{item.height}}
					</view>
					<view class="type" >
						<txet class="xiaobiao" v-for="(v,k) in item.lable_arr.show_lable">{{v.lable}}</txet>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>
<script setup>
	import {ref,onUpdated,reactive,computed,onMounted} from 'vue';
	import sheep from '@/sheep';
	import {onLoad,onUnload} from '@dcloudio/uni-app';
	const state = reactive({
		text:"",
		list:[],
		pageSize:10,
		hasMore:true,
		isLoad:false,
	})
	onLoad(res=>{
	})
	
	function newsDatas(){
		state.page=1
		state.hasMore=true
		state.isLoad=false
		state.list=[]
		getGoodsList()
	}
	async function getGoodsList(){
		if(state.isLoad) return false
		if(!state.hasMore) return false
		state.isLoad=true
		const {code,data} = await sheep.$api.zqzApi.indexNews({
			title:state.text,
			page:state.page,
			limit:state.pageSize,
		})
		if (code == 1) {
			let list = data.list
			let hasmore = list.length===state.pageSize
			list = state.list.concat(list)
			state.hasMore = hasmore
			state.list = list
			state.isLoad = false
			state.page = state.page+1
		}
	}
</script>
<style lang="scss" scoped>
	.ov1 {
		width:80%;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}
	
	page{background: #f5f5f5; width: 100%; height: 100%;}
	.box{width: 100%; height: calc(100% - 20rpx); padding-top: 20rpx;}
	.box .top{width: calc(100% - 104rpx); margin-left: 32rpx; display: flex; padding: 15rpx; border-radius: 50rpx; height: 40rpx; background: #e7e7e7; align-items: center; justify-content: space-between;}
	.box .top image{width: 32rpx; height: 32rpx;}
	.box .top .sou{width: 80rpx; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 26rpx;}
	.box .top input{width: calc(100% - 150rpx);}
	.marTop{width: 100%; height: calc(100% - 100rpx); margin-top: 20rpx;}
	
	.all_list {
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		justify-content: space-between;
		width: calc(100% - 48rpx);
	    margin:0 auto;
		padding-bottom: 100rpx;
		
	
		.block {
			width: 48%;
			height: 518rpx;
			background: #F8F8F8;
			border-radius: 24rpx;
			background-color: #fff;
			margin-bottom: 24rpx;
	
			.img {
				width: 100%;
				height: 332rpx;
				border-radius: 24rpx 24rpx 0 0;
				overflow: hidden;
	
				image {
					width: 100%;
					height: 332rpx;
				}
			}
	
			.title {
				display: flex;
				align-items: center;
				margin: 20rpx 24rpx 4rpx;
	
				image {
					height: 32rpx;
					width: 32rpx;
				}
	
				text {
					font-size: 32rpx;
					color: #333333;
					margin-left: 8rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
				}
			}
	
			.infos {
				font-size: 24rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				color: #A5A5A5;
				margin: 4rpx 24rpx 12rpx;
			}
	
			.type {
				padding:0 24rpx;
				display: flex;
				.xiaobiao{
					padding:5rpx 8rpx;
					text-align: center;
					border-radius: 30rpx;
					font-size: 18rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #333333;
					margin-right: 8rpx;
					background: #1BDDD0;
					color: #fff;
				}
				
			}
		}
	}
</style>